package com.wongoing.datasource;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class DataSourceExchange implements MethodInterceptor {

	public Object invoke(MethodInvocation invocation) throws Throwable {
		//获取所有的参数
		Object[] params = invocation.getArguments();
		if(params.length > 0){
			DataSourceHolder.setDataSource(params[0].toString());
		}
		Object returnObject = invocation.proceed();
		DataSourceHolder.clearDataSource();
		
		return returnObject;
	}

}
